package com.cgbl.cg.adapter

import android.os.Bundle
import androidx.appcompat.widget.AppCompatImageView
import com.cgbl.cg.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.robot.base.configs.AppConstants
import com.robot.base.model.CourseBean
import com.robot.base.util.arouter.ARouterUtil
import com.robot.base.utils.pic.ImageLoaderUtils

class CourseMenuAdapter :
    BaseQuickAdapter<CourseBean, BaseViewHolder>(R.layout.app_item_course_menu) {
    override fun convert(holder: BaseViewHolder, item: CourseBean) {
        holder.setText(R.id.item_tv_name, item.courseName)
            .setText(R.id.item_tv_num, "${item.countStudy}人在学·${item.classHour}小时")
        holder.itemView.setOnClickListener {
            ARouterUtil.goToActivityWithBundle(AppConstants.Router.Mine.A_MINE_COURSE_PROFILE,
                Bundle().apply {
                    putString(AppConstants.BundleKey.ID, item.courseId)
                })
        }
        val ivImg = holder.getView<AppCompatImageView>(R.id.item_iv_1)
        ImageLoaderUtils.displayRound(context, ivImg, item.courseCoverImage, 10)
    }
}